home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_c
/
cuj0696.zip
/
DWYER.ZIP
/
GAP.TST
/
GAPCOD.TXT
< prev
next >
Wrap
Text File
|
1996-02-12
|
2KB
|
56 lines
PSEUDO CODE FOR KOLMOGOROV-SMIRNOV TEST IN GAP TEST
This algorithm calculates Kolmogorov-Smirnov statistics and
probabilities for a set of gap lengths specified by the user.
First, 100 chi-square probabilities are calculated and stored.
These probabilities are used to calculate Kolmogorov-Smirnov
statistics and probabilities and the results are printed. This
algorithm is largely due to D.E. Knuth [K1, pp. 60-61].
Inputs:
C = Number of Categories (= G+1)
E = Array of Cell Expectations, One for Each Category
L = Lower Bound of Gap, 0 <= L <= H <= 1
H = Higher Bound of Gap
G = Maximum Gap Length to be Tabulated
N = Number of Gaps to be Tabulated
U() = Uniform Random Number Generator Function Under Test
G1. [Initialize.] Set F <- C-1. (This is the number of degrees
of freedom which serves as input to chdtr(), the chi-square
probability distribution function.)
G2. [Generate Data for KS test.] Set t <- 1. (We will execute
steps G3 to G12 100 times, then go on to G13.)
G3. [Calculate next chi-square statistic.] Set k <- 0, SoS <- 0,
ChiSq <- -N, and set Count[i] <- 0, 1 <= i <= C.
G4. [Initialize gap counter.] Set g <- 0.
G5. [Check for Gap.] Set N <- U(). If L <= N <= H, a gap of length
g has been found; go to step G7.
G6. [Increment k.] Increase g by 1, go back to step G5.
G7. [Tally gap length.] If g > G, set g <- G. Increase Count[g] by 1.
G8. [Test end.] Increase k by 1. If k < N, go back to step G4.
Otherwise, a complete set of gaps has been tabulated.
Go to step G9.
G9. [Calculate sum of squares.] SoS <- SoS + Count[j], 1 <= j <= G.
G10. [Finish chi-square statistic.] ChiSq <- ChiSq + Count[j]^2 / E[j],
1 <= j <= C.
G11. [Calculate p-value.] XsqProb[t] <- chdtr(F, ChiSq).
G12. [Test end.] Increase t by 1. If t <= 100, go back to step G3.
G13. [Calculate K-S data.] Execute function KSCalc() to get K-S
statistics and probabilities. There will be four quantities
produced - Kn+, Pn+, Kn-, Pn-.
G14. [Print Results.] Print Kn+, Pn+, Kn-, Pn-.